﻿<p>
    This example shows the client-side events supported by Telerik Window for ASP.NET
    MVC.
</p>
<p>
    The window has the following events:
</p>
<ul>
    <li><strong>OnLoad</strong> - raised when the component is initialized</li>
    <li><strong>OnOpen <span class="cancellable">(cancellable)</span></strong> - raised
        when the window is opened</li>
    <li><strong>OnClose <span class="cancellable">(cancellable)</span></strong> - raised
        when the window is closed</li>
    <li><strong>OnRefresh</strong> - raised
        when the window content is re-loaded</li>
</ul>
<p>
    You can subscribe to each of the events in the following ways:</p>
<ul>
    <li>With a pre-defined javascript function
        <pre class="prettyprint">
&lt;%= Html.Telerik().Window()
        .Name("Window")
        .ClientEvents(events => events
            <em>.OnLoad("OnLoad")</em>
        )
%&gt;

&lt;script type="text/javascript"&gt;
    function OnLoad(e) {
        // your code
    }
&lt;/script&gt;
</pre>
    </li>
    <li>With an inline function, serialized from the server
        <pre class="prettyprint">
&lt;% Html.Telerik().Window()
       .Name("Window")
       .ClientEvents(events => events
       <em>.OnLoad(() => {%&gt; function(e) { // your code } &lt;%})</em>
       .Render();
%&gt;
</pre>
    </li>
    <li>Purely client-side event registration
        <pre class="prettyprint">
&lt;%= Html.Telerik().Window().Name("Window") %&gt;

&lt;script type="text/javascript"&gt;
    $(document).ready(function() {
        <em>$('#Window').bind('open', function(e) { // your code });</em>
    });
&lt;/script&gt;
</pre>
    </li>
</ul>
